package com.golang.api.util;


public interface Assert<T extends RuntimeException> {

  /**
   * 创建异常
   *
   * @return
   */
  T newException ();

  /**
   * 创建异常
   *
   * @param args
   * @return
   */
  T newException (Object... args);


  default void assertNotNull (Object obj) {
    if (obj == null) {
      throw newException(obj);
    }
  }

  default void assertNotNull (Object obj, Object... args) {
    if (obj == null) {
      throw newException(args);
    }
  }


  default void assertNotBlank (String str, Object... args) {
    if (str == null || "".equals(str)) {
      throw newException(args);
    }
  }

  default void assertNotBlank (String str) {
    if (str == null || "".equals(str)) {
      throw newException();
    }
  }

}
